﻿using Google.Protobuf;

namespace ZFramework.Runtime
{
    public class S2CMessageEventArgs : GameEventArgs
    {
        public static int EventId = typeof(S2CMessageEventArgs).GetHashCode();
        
        public override int Id
        {
            get { return EventId; }
        }
        
        public int PacketId
        {
            get;
            private set;
        }
        
        public int ReqId
        {
            get;
            private set;
        }

        public string MsgName
        {
            get;
            private set;
        }

        public IMessage msg
        {
            get;
            private set;
        }

        public override void Clear()
        {
            PacketId = 0;
            ReqId = 0;
            MsgName = string.Empty;
            msg = null;
        }

        public static S2CMessageEventArgs Create(int packetId, int reqId, string msgName, IMessage msg)
        {
            var args = ReferencePool.Acquire<S2CMessageEventArgs>();
            args.PacketId = packetId;
            args.ReqId = reqId;
            args.MsgName = msgName;
            args.msg = msg;
            return args;
        }
    }
}